package com.kamistoat.ruoyi.ruoyimodulessystem.controller;

import java.util.Arrays;
import java.util.Map;


import com.kamistoat.ruoyi.ruoyicommoncore.utils.page.PageUtils;
import com.kamistoat.ruoyi.ruoyicommoncore.web.domain.AjaxResult;
import com.kamistoat.ruoyi.ruoyimodulessystem.service.SysRoleDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.kamistoat.ruoyi.ruoyiapisystem.entity.SysRoleDeptEntity;




/**
 * 角色和部门关联表
 *
 * @author kamistoat
 * @email linjianshanke@163.com
 * @date 2022-08-09 10:34:46
 */
@RestController
@RequestMapping("/roledept")
public class SysRoleDeptController {
    @Autowired
    private SysRoleDeptService sysRoleDeptService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    // @RequiresPermissions("ruoyiapisystem:sysroledept:list")
    public AjaxResult list(@RequestParam Map<String, Object> params){
        PageUtils page = sysRoleDeptService.queryPage(params);

        return AjaxResult.success().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{roleId}")
    // @RequiresPermissions("ruoyiapisystem:sysroledept:info")
    public AjaxResult info(@PathVariable("roleId") Long roleId){
		SysRoleDeptEntity sysRoleDept = sysRoleDeptService.getById(roleId);

        return AjaxResult.success().put("sysRoleDept", sysRoleDept);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    // @RequiresPermissions("ruoyiapisystem:sysroledept:save")
    public AjaxResult save(@RequestBody SysRoleDeptEntity sysRoleDept){
		sysRoleDeptService.save(sysRoleDept);

        return AjaxResult.success();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    // @RequiresPermissions("ruoyiapisystem:sysroledept:update")
    public AjaxResult update(@RequestBody SysRoleDeptEntity sysRoleDept){
		sysRoleDeptService.updateById(sysRoleDept);

        return AjaxResult.success();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    // @RequiresPermissions("ruoyiapisystem:sysroledept:delete")
    public AjaxResult delete(@RequestBody Long[] roleIds){
		sysRoleDeptService.removeByIds(Arrays.asList(roleIds));

        return AjaxResult.success();
    }

}
